<?php require_once('Connections/conex.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}


$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}


//GUARDO LOS DATOS DE LA EXPERIENCIA EN EL CAMPO idpostulante CON LA VARIABLE QUE CAPTURE ANTERIORMENTE ($_SESSION['id']) 
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO experiencias (idpostulante, empresa, puesto, referencia) VALUES (%s, %s, %s, %s)",
                       GetSQLValueString($_SESSION['id'], "int"),
                       GetSQLValueString($_POST['empresa'], "text"),
                       GetSQLValueString($_POST['puesto'], "text"),
                       GetSQLValueString($_POST['referencia'], "text"));

  mysql_select_db($database_conex, $conex);
  $Result1 = mysql_query($insertSQL, $conex) or die(mysql_error());

  $insertGoTo = "postulantes_cargar3.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
?>

<?php
$PAGE = 'postulantes_cargar2';
$TIPO = 'frontend';
$TITLE = 'Cargar Experiencias Laborales';
?> 

<!-- empieza la página-->
   
   <?php include('includes/head.php') ?>
   
    <body id="<?php echo $PAGE; ?>" class="<?php echo $PAGE; ?>">
     
     <?php include('includes/cabecera.php') ?>
       
     <?php include('includes/intro.php') ?>
        
     <?php if ($PAGE == 'home') { ?>
     <?php include('includes/cols.php') ?>
     <?php } ?>
        
     <div id="contenido">
     
     	<div id="main">
        
                    
            <h1>Cargar Curriculum</h1>
            <h2>Experiencias Laborales</h2>
            <form method="post" name="form1" action="<?php echo $editFormAction; ?>">
              <table>
                <tr valign="baseline">
                  <td nowrap align="right">Empresa:</td>
                  <td><input type="text" name="empresa" value="" size="32"></td>
                </tr>
                <tr valign="baseline">
                  <td nowrap align="right">Puesto:</td>
                  <td><input type="text" name="puesto" value="" size="32"></td>
                </tr>
                <tr valign="baseline">
                  <td nowrap align="right">Referencia:</td>
                  <td><input type="text" name="referencia" value="" size="32"></td>
                </tr>
                <tr valign="baseline">
                  <td nowrap align="right">&nbsp;</td>
                  <td><input type="submit" value="Aceptar y Continuar"></td>
                </tr>
              </table>
              <input type="hidden" name="MM_insert" value="form1">
            </form>
            
            <a href="postulantes_cargar3.php">No tengo experiencias laborales</a>

		</div><!-- fin main-->
        
        <div id="columna">
   			<?php include('includes/columna.php') ?>
        </div>
         
            
     </div>
        
     <hr class="noscreen" />

        
     <?php include('includes/pie.php') ?>

<!-- termina la página-->